USE [MSQDB]
GO

/****** Object:  Table [dbo].[TOOL_IMPORT_DETAIL]    Script Date: 9/14/2014 1:30:25 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TOOL_IMPORT_DETAIL](
	[IdTool] [varchar](30) NOT NULL,
	[IdImport] [int] NOT NULL,
	[Quantity] [int] NOT NULL,
	[Reason] [varchar](200) NOT NULL,
	[Price] [int] NOT NULL,
	[TotalCost] [int] NOT NULL,
 CONSTRAINT [PK_TOOL_IMPORT_DETAIL] PRIMARY KEY CLUSTERED 
(
	[IdTool] ASC,
	[IdImport] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL] ADD  CONSTRAINT [DF_TOOL_IMPORT_DETAIL_Price]  DEFAULT ((0)) FOR [Price]
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL] ADD  CONSTRAINT [DF_TOOL_IMPORT_DETAIL_TotalCost]  DEFAULT ((0)) FOR [TotalCost]
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL]  WITH CHECK ADD  CONSTRAINT [FK_TOOL_IMPORT_DETAIL_TOOL] FOREIGN KEY([IdTool])
REFERENCES [dbo].[TOOL] ([Id])
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL] CHECK CONSTRAINT [FK_TOOL_IMPORT_DETAIL_TOOL]
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL]  WITH CHECK ADD  CONSTRAINT [FK_TOOL_IMPORT_DETAIL_TOOL_IMPORT] FOREIGN KEY([IdImport])
REFERENCES [dbo].[TOOL_IMPORT] ([Id])
GO

ALTER TABLE [dbo].[TOOL_IMPORT_DETAIL] CHECK CONSTRAINT [FK_TOOL_IMPORT_DETAIL_TOOL_IMPORT]
GO


